package org.micropayment.provider.oauth.service;

import org.micropayment.model.MicropaymentUser;
import org.springframework.dao.DataAccessException;
import org.springframework.security.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.micropayment.model.service.MicropaymentUserDAO;

/**
 *
 * @author jj
 */
@Service("micropaymentUserDetailsService")
public class MicropaymentUserDetailsService implements UserDetailsService {

    private static Logger logger =
            LoggerFactory.getLogger(MicropaymentUserDetailsService.class);

    @Autowired MicropaymentUserDAO userDao;

    public UserDetails loadUserByUsername(String login)
            throws UsernameNotFoundException, DataAccessException {
        MicropaymentUser user = userDao.findByUserId(login);
        return user;
    }

}